package com.ciei.dpagm.controller;

import com.alibaba.fastjson.JSONObject;
import com.ciei.dpagm.common.controller.BaseController;
import com.ciei.dpagm.service.CompanyService;
import com.ciei.dpagm.util.PageParam;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class CompanyController extends BaseController {
	@Autowired
	private CompanyService companyService;

	/**
	 * 客户管理-新增客户
	 */
	@RequiresPermissions("system:company:add")
	@RequestMapping("vue/company/add")
	@ResponseBody
	public JSONObject addVue(@RequestBody JSONObject jsonObject) {
		return companyService.addOrUpdateVue(jsonObject,"add");
	}

	/**
	 * 客户管理-修改客户
	 */
	@RequiresPermissions("system:company:edit")
	@RequestMapping("vue/company/update")
	public @ResponseBody JSONObject updateVue(@RequestBody JSONObject jsonObject) {
		return companyService.addOrUpdateVue(jsonObject,"edit");
	}

	/**
	 * 客户管理-删除客户
	 */
	@RequiresPermissions("system:company:del")
	@RequestMapping("vue/company/delete")
	@ResponseBody
	public JSONObject deleteVue(@RequestBody JSONObject jsonObject) {
		return companyService.deleteVue(jsonObject);
	}

	/**
	 * 加载公司数据，以网格形式显示
	 * @param  :0客户公司；1：生产厂家
	 * @author pp
	 * @return
	 */
	@RequestMapping("vue/company/loadGrid")
	@ResponseBody
	public JSONObject loadGridVue(@RequestBody JSONObject page) {
		PageParam ps=getPageParams(page);
		return companyService.loadGridVue(ps);
	}
}
